<?php defined('IN_IA') or exit('Access Denied');?><?php (!empty($this) && $this instanceof WeModuleSite || 1) ? (include $this->template('common/header', TEMPLATE_INCLUDEPATH)) : (include template('common/header', TEMPLATE_INCLUDEPATH));?>
<?php (!empty($this) && $this instanceof WeModuleSite || 1) ? (include $this->template('base/css', TEMPLATE_INCLUDEPATH)) : (include template('base/css', TEMPLATE_INCLUDEPATH));?>
<style>
    td{vertical-align: middle!important}
    .btn-group{margin-bottom:15px;}
</style>

<div class="btn-group" role="group" aria-label="...">
    <a href="<?php  echo aurl(2)?>" class="btn btn-default">新增</a>
    <a href="#" class="btn btn-default check-all-control">全选</a>
    <a href="<?php  echo aurl(4)?>" class="btn btn-default ajax-post confirm" data-confirm="确定要删除勾选项吗?">删除</a>
</div>
<form action="javascript:void(0)" method="POST" id="form">
<table class="table table-striped">
    <tr>
        <th>#</th>
        <th>活动ID</th>
        <th width="30%">标题</th>
        <th>预付费</th>
        <!-- <th>成团人数</th> -->
        <th>添加时间</th>
        <th>过期时间</th>
        <th>状态</th>
        <th>操作</th>
    </tr>
    <?php  if(is_array($list)) { foreach($list as $item) { ?>
    <tr>
        <td><input type="checkbox" name="id[]" class="check-all" value="<?php  echo $item['id'];?>"></td>
        <td><?php  echo $item['id'];?></td>
        <td><?php  echo $item['title'];?></td>
        <td>￥<?php  echo $item['price'];?></td>
        <!-- <td><?php  echo $item['group_map'];?></td> -->
        <td><?php  echo date('Y-m-d', $item['create_time'])?></td>
        <td><?php  echo date('Y-m-d', $item['end_time'])?></td>
        <td><?php  echo active_name($item['status'])?></td>
        <td>
            <label><a href="<?php  echo aurl(2, ['pid'=>$item['id']])?>">修改</a></label>
            <label><a href="<?php  echo aurl(6, ['pid'=>$item['id']])?>">订单</a></label>
            <label><a class="modal-control" data-title="<?php  echo $item['title'];?>" data-img="<?php  echo aurl(11, ['pid'=>$item['id']])?>" data-link="<?php  echo web2app_url('main', ['pid'=>$item['id']], '', $share_url)?>" href="javascript:;">预览</a></label>
            <label class="dropdown">
                <a id="dLabel" data-target="#" href="http://example.com" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">更多<span class="caret"></span></a>
                <ul class="dropdown-menu" aria-labelledby="dLabel">
                    <li><a href="<?php  echo aurl(2, ['copyid'=>$item['id']])?>">复制活动</a></li>
                    <li><a href="<?php  echo aurl(['et'=>10, 'pid'=>$item['id']])?>">开团列表</a></li>
                    <li><a href="<?php  echo aurl(['et'=>14, 'pid'=>$item['id']])?>">报名成员</a></li>
                    <li><a href="<?php  echo aurl(['et'=>18, 'pid'=>$item['id']])?>">成团礼</a></li>
                    <li><a href="<?php  echo aurl(['et'=>20, 'pid'=>$item['id']])?>">虚拟数据设置</a></li>
                </ul>
            </label>
        </td>
    </tr>
    <?php  } } ?>
</table>
<?php  echo $page;?>
</form>
<div class="modal fade bs-example-modal-sm" id="modal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
    <div class="modal-dialog modal-sm" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title" id="myModalLabel"><?php  echo $item['title'];?></h4>
            </div>
            <div class="modal-body">
                <p align="center"><img src="<?php  echo aurl(['et'=>11,'pid'=>$item['id']])?>" id="qrcodeLabel" width="200"></p>
                <p class="help-block">* 请使用微信扫描二维码查看活动或 <a href="javascript:;" class="cliplink" data-text="<?php  echo web2app_url('main', ['pid'=>$item['id']], '', $share_url)?>">复制活动链接</a></p>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭页面</button>
            </div>
        </div>
    </div>
</div>

<?php (!empty($this) && $this instanceof WeModuleSite || 1) ? (include $this->template('base/js', TEMPLATE_INCLUDEPATH)) : (include template('base/js', TEMPLATE_INCLUDEPATH));?>
<script>
    requirejs.config({
        appDir: '.',
        paths: {
            'clipboard': ['<?php echo WEB_RESOURCE;?>/library/clipboard.min']
        }
    });
    require(['clipboard', 'jquery'], function(Clipboard, $) {

        $('.modal-control').on('click', function() {
            var data = $(this).data();
            $('#modal').find('.modal-title').html(data.title);
            $('#modal').find('#qrcodeLabel').prop('src', data.img);
            $('#modal').find('.cliplink').attr('data-text', data.link);
            $('#modal').modal('show');
        })

        $('#modal').on('hidden.bs.modal', function () {
            $('#modal').find('.modal-title').html('');
            $('#modal').find('#qrcodeLabel').prop('src', '');
            $('#modal').find('.cliplink').attr('data-text', '');
        });
        
        var clipboard = new Clipboard('.cliplink', {
            container: document.getElementById('modal'),
            text: function(e) {
                return $(e).attr('data-text');
            }
        });
        clipboard.on('success', function(e) {
            xalert('复制成功', true, true);
        });
        clipboard.on('error', function() {
            xalert('复制失败', false, true);
        });
    });
    
</script>

<?php (!empty($this) && $this instanceof WeModuleSite || 1) ? (include $this->template('common/footer', TEMPLATE_INCLUDEPATH)) : (include template('common/footer', TEMPLATE_INCLUDEPATH));?>